<!DOCTYPE html>

<!--
 * Copyright 2011, Vladimir Kostyukov & Alexei Zavjalov
 * 
 * This file is part of losharik project (http://losharik.googlecode.com)
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * You may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 *      
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
-->

<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
	<title>Losharik@beta</title>
		
	<link rel="stylesheet" type="text/css" href="style.css" />
	<script type="text/javascript" src="http://userapi.com/js/api/openapi.js?34"></script>
	<script type="text/javascript" src="losharik.js"></script>
	<script type="text/javascript">
	
	function DefaultResources() {
		this.MENU = document.getElementById("menu");
		this.MENU_PLAY = document.getElementById("playBtn");
		this.MENU_RECORDS = document.getElementById("recordsBtn");
		this.MENU_HELP = document.getElementById("helpBtn");
		this.RECORDS_BACK_BTN = document.getElementById("recordsBackBtn");
		this.RECORDS = document.getElementById("records");
		this.HELP = document.getElementById("help");
		this.HELP_BACK_BTN = document.getElementById("helpBackBtn");
		this.CANVAS = document.getElementById("canvas");
		this.BACKGROUND = document.getElementById("background");
		this.ROLL_LEFT = document.getElementById("rollLeft");
		this.ROLL_RIGHT = document.getElementById("rollRight");
		this.SCORE = document.getElementById("score");
		this.LIVE = document.getElementById("live");
		this.PLATFORM = document.getElementById("platform");
		this.ICE_PLATFORM = document.getElementById("icePlatform");
		this.KILLER_PLATFORM = document.getElementById("killerPlatform");
	}

	function createGame() {

		var resources = new DefaultResources();
		var game = new Game(new GameModel(), new HTML5View(resources), new KeyboardController());

		resources.MENU_PLAY.onclick = game.play;
		resources.MENU_RECORDS.onclick = game.records;
		resources.MENU_HELP.onclick = game.help;
		resources.RECORDS_BACK_BTN.onclick = game.menu;
		resources.HELP_BACK_BTN.onclick = game.menu;

		game.restart = createGame;;

		return game;
	}

	function main() {
		var game = createGame();
		game.menu();
	}

	VK.init({apiId: 2657907, onlyWidgets: true});

	</script>
</head>
<body onload="main();">
	 <div id="menu" style="display: none;">
		<input type="button" id="playBtn" value="Play" />
		<input type="button" id="recordsBtn" value="Records" />
		<input type="button" id="helpBtn" value="Help" />
		<input type="button" value="Exit" onClick="self.close();" />
		<div id="vk_like"></div>
		<script type="text/javascript">
		VK.Widgets.Like("vk_like", {type: "mini"});
		</script>
	</div>

	<div id="records" style="display:none;">
		<span> </span>
		<input type="button" id="recordsBackBtn" value="Back" />
	</div>

	 <div id="help" style="display:none;">
	 	<span> </span>
		<input type="button" id="helpBackBtn" value="Back" />
	 </div>

	<!-- RESOURCES -->	
	<img id="background" alt="background" src="../img/bg.png" style="display:none" />
	<img id="rollLeft" alt="rollLeft" src="../img/roll_left.png" style="display:none" />
	<img id="rollRight" alt="rollRight" src="../img/roll_right.png" style="display:none" />
	<img id="score" alt="score" src="../img/score.png" style="display:none" />
	<img id="live" alt="live" src="../img/live.png" style="display:none" />
	<img id="platform" alt="platform" src="../img/platform.png" style="display:none" />
	<img id="icePlatform" alt="icePlatform" src="../img/ice_platform.png" style="display:none" />
	<img id="killerPlatform" alt="killerPlatform" src="../img/killer_platform.png" style="display:none" />
		
	<canvas id="canvas" width="320" height="480" style="display:none;"></canvas>
</body>
</html>